//go:build wireinject
// +build wireinject

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/google/wire"
	"github.com/honwee/awm/internal/api/handler"
	"github.com/honwee/awm/internal/api/router"
	"github.com/honwee/awm/internal/repository"
	"github.com/honwee/awm/internal/service"
)

// ProvideGinEngine 提供gin引擎实例
func ProvideGinEngine() *gin.Engine {
	return gin.Default()
}

// ServerSet 服务器相关的提供者集合
var ServerSet = wire.NewSet(
	ProvideGinEngine,
	NewServer,
)

// HandlerSet 处理器相关的提供者集合
var HandlerSet = wire.NewSet(
	handler.NewTraceHandler,
	handler.NewWorkflowRunHandler,
	handler.NewProjectUserHandler,
)

// ServiceSet 服务相关的提供者集合
var ServiceSet = wire.NewSet(
	service.NewTraceService,
	service.NewWorkflowRunService,
	service.NewProjectUserService,
)

// RepositorySet 仓储相关的提供者集合
var RepositorySet = wire.NewSet(
	repository.NewTraceRepository,
	repository.NewWorkflowRunRepository,
	repository.NewProjectUserRepository,
)

// RouterSet 路由相关的提供者集合
var RouterSet = wire.NewSet(
	router.NewRouter,
)

// AppSet 应用程序完整的提供者集合
var AppSet = wire.NewSet(
	ServerSet,
	HandlerSet,
	ServiceSet,
	RepositorySet,
	RouterSet,
)

// InitializeServer 初始化服务器
func InitializeServer() (*Server, error) {
	wire.Build(AppSet)
	return nil, nil
}
